
    
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title">编辑</h4>
                    </div>
                    <form class="form-horizontal m-t" id="myForm">
                        <div class="modal-body">
                            <!--错误信息提示-->
                            <div id="errormessage" class="alert alert-danger text-center" style="display:none">&nbsp;</div>
                            <input type="hidden" name="id" value="{{=ormdata.id}}" />
                            <div class="form-group">
                                <label class="col-sm-3 control-label">菜单名</label>
                                <div class="col-sm-8">
                                    <input id="menuname" name="menuname" class="form-control" type="text" value="{{=ormdata.menuname}}" placeholder="菜单名">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">URL地址</label>
                                <div class="col-sm-8">
                                    <input id="menuurl" name="menuurl" class="form-control" type="text" value="{{=ormdata.menuurl}}" placeholder="菜单访问URL地址">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">菜单图标</label>
                                <div class="col-sm-8">
                                    <input type="text" id="menuicon" name="menuicon" value="{{=ormdata.menuicon}}"  />
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">菜单类型</label>

                                <div class="col-sm-8">
                                    <select class="form-control m-b" name="menutype" id="menutype">
                                        {{ if ormdata.menutype == 1:}}
                                            <option value="1" selected="selected">菜单</option>
                                            <option value="2">功能</option>
                                        {{ else:}}
                                            <option value="1" >菜单</option>
                                            <option value="2" selected="selected" >功能</option>
                                        {{ pass}}
                                    </select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">菜单序号</label>
                                <div class="col-sm-8">
                                    <input id="menuseq" name="menuseq" class="form-control" type="text" value="{{=ormdata.menuseq}}" placeholder="菜单序号">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">上级菜单</label>
                                <div class="col-sm-8">
                                    <div id="menupid"></div>
                                </div>
                            </div>
                        </div>
                        
                        <div class="modal-footer">
                            <button type="button" class="btn btn-white" data-dismiss="modal" >关闭</button>
                            <button type="submit" class="btn btn-primary">保存</button>
                        </div>
                        </form>


<script src="{{=url_for_static('js/jquery.menuselect.js')}}" type="text/javascript"></script>
<script>
    var fnt_icons_categorized = {
        'web应用' : ["icon-mail", "icon-mail-alt", "icon-th-large", "icon-th", "icon-th-list", "icon-help-circled", "icon-info-circled", "icon-info", "icon-home", "icon-link", "icon-unlink", "icon-link-ext", "icon-link-ext-alt", "icon-attach", "icon-tag", "icon-tags", "icon-bookmark", "icon-bookmark-empty", "icon-download", "icon-upload", "icon-download-cloud", "icon-upload-cloud", "icon-reply", "icon-reply-all"],
        '表格控件' : ["icon-search", "icon-ok", "icon-ok-circled", "icon-ok-circled2", "icon-ok-squared", "icon-cancel", "icon-cancel-circled", "icon-cancel-circled2", "icon-plus", "icon-plus-circled", "icon-plus-squared", "icon-minus", "icon-minus-circled", "icon-minus-squared", "icon-minus-squared-alt", "icon-quote-right", "icon-comment-empty", "icon-chat-empty","icon-export", "icon-export-alt", "icon-pencil", "icon-pencil-squared", "icon-edit", "icon-print"],
        '品牌' : ["icon-android", "icon-apple", "icon-drupal", "icon-facebook", "icon-github", "icon-google", "icon-html5", "icon-linux", "icon-qq", "icon-wechat", "icon-windows"],
        '常用' : ["icon-heart", "icon-heart-empty", "icon-star", "icon-star-empty", "icon-star-half-alt", "icon-user", "icon-users", "icon-male", "icon-female", "icon-forward", "icon-quote-left", "icon-retweet", "icon-keyboard", "icon-gamepad", "icon-comment", "icon-chat"],
        '其它' : ["icon-file-pdf", "icon-help", "icon-lock", "icon-lock-open", "icon-lock-open-alt", "icon-pin", "icon-th-large", "icon-flag", "icon-flag-empty", "icon-flag-checkered", "icon-thumbs-up", "icon-thumbs-down", "icon-thumbs-up-alt", "icon-thumbs-down-alt", "icon-bell", "icon-bell-alt","icon-cog"]
    };
    $(document).ready(function() {

            $('#menuicon').fontIconPicker({
                    source: fnt_icons_categorized,
                    theme: 'fip-bootstrap',
                    allCategoryText: '所有图标'
            });

            $("#myForm").validate({
                rules: {
                    menuname : {
                        required : true
                    },
                    menuurl : {
                        required : true
                    },
                    menuseq : {
                        required : true,
                        isInteger: true,
                        isIntGtZero: true,
                        maxlength: 3
                    },
                },
                messages: {
                    menuseq: "请输入大于0的整数",
                },
                submitHandler: function(form) {  //通过之后回调
                    var data = $(form).serialize();
                     $.ajax({ 
                        url : "/menu/menusave", 
                        type : "post", 
                        dataType : "json", 
                        data: data, 
                        success : function(d) { 
                            if (d.status==200){
                                $("#modaledit").modal('hide');
                                //刷新表格
                                $table.bootstrapTable('refresh');
                                swal({
                                    title: "操作成功",
                                    text: "2秒自动关闭",
                                    timer: 2000,
                                    type: "success",
                                    confirmButtonColor: "#DD6B55",
                                    confirmButtonText: "确定",
                                });
                            }else{
                                $("#errormessage").show().html("<h4>" + d.msg + "</h4>");
                            }
                        } 
                    }); 
                }, 
                invalidHandler: function(form, validator) {  //不通过回调 
                       return false; 
                } 
            });
            

        $("#menupid").MenuSelect({data:"{{=ormdata.menupath}}"});  //设置初始值为0,1,4
    });
</script>

